#! /bin/sh

MODULE_NAME="e581"
CDEV_NAME="/dev/e581"

############ 确定用户具有管理员权限
find_user()
{
    user=$1
}
find_who()
{
    WHO=`who`
    find_user WHO
    if [ $user != root ]
    then
	echo "please switch user to root!"
	exit 1
    else
	SUDO=
    fi
}

#是否用户具有管理员权限
which sudo > /dev/null
if [ $? == 0 ]
then
    SUDO=sudo
else
    find_who
fi


if [ -c $CDEV_NAME ]
then
    $SUDO rm -f $CDEV_NAME
fi

lsmod | grep $MODULE_NAME > /dev/null
if [ $? == 0 ]
then
    $SUDO rmmod $MODULE_NAME
fi

echo "remove all driver resource"
